#ifndef RP2STENCILSTATE_H
#define RP2STENCILSTATE_H

#include "Rp2GlobalState.h"

namespace Rp2
{
class StencilState : public GlobalState
{
RP2_DECLARE_INITIALIZE;
RP2_DECLARE_TERMINATE;

public:
	StencilState();
	virtual ~StencilState();
	
	virtual StateType GetStateType() const { return STENCIL; }

    enum CompareFunction
    {
        CF_NEVER,
        CF_LESS,
        CF_EQUAL,
        CF_LEQUAL,
        CF_GREATER,
        CF_NOTEQUAL,
        CF_GEQUAL,
        CF_ALWAYS,
        CF_QUANTITY
    };

    enum OperationType
    {
        OT_KEEP,
        OT_ZERO,
        OT_REPLACE,
        OT_INCREMENT,
        OT_DECREMENT,
        OT_INVERT,
        OT_QUANTITY
    };

    bool Enabled;             // default: false
    CompareFunction Compare;  // default: CF_NEVER
    unsigned int Reference;   // default: 0
    unsigned int Mask;        // default: ~0
    unsigned int WriteMask;   // default: ~0
    OperationType OnFail;     // default: OT_KEEP
    OperationType OnZFail;    // default: OT_KEEP
    OperationType OnZPass;    // default: OT_KEEP
};

RP2_REGISTER_INITIALIZE(StencilState);
RP2_REGISTER_TERMINATE(StencilState);
typedef Pointer<StencilState> StencilStatePtr;

}

#endif